package com.example.demo.commom;

import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:龙宝
 * Date:2023-11-09
 * Time:20:55
 */
@Data
public class AjaxResult {
    private Integer code;//200表示成功返回,-1表示错误信息数据的返回
    private String msg;
    private String data;

    //成功
    public static AjaxResult success(String data) {
        AjaxResult result = new AjaxResult();
        result.setCode(200);
        result.setMsg("");
        result.setData(data);
        return result;
    }
    public static AjaxResult success(Integer code,String data) {
        AjaxResult result = new AjaxResult();
        result.setCode(code);
        result.setMsg("");
        result.setData(data);
        return result;
    }

    //失败
    public static AjaxResult fail(String msg) {
        AjaxResult result = new AjaxResult();
        result.setCode(-1);
        result.setMsg(msg);
        result.setData("");
        return result;
    }
    public static AjaxResult fail(Integer code,String msg) {
        AjaxResult result = new AjaxResult();
        result.setCode(code);
        result.setMsg(msg);
        result.setData("");
        return result;
    }

}
